﻿using Exercises;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace ExercisesTest
{
    
    
    /// <summary>
    ///This is a test class for StudentTest and is intended
    ///to contain all StudentTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StudentTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for FirstBeforeLast
        ///</summary>
        [TestMethod()]
        public void FirstBeforeLastTest()
        {
            IEnumerable<Student> students = new Student[]{new Student("a","b"), new Student("c","d"), new Student("d","c"), new Student("b","a")}; // TODO: Initialize to an appropriate value
            Student[] expected = new Student[]{new Student("a","b"), new Student("c","d")}; // TODO: Initialize to an appropriate value
            List<Student> actual;
            actual = Student.FirstBeforeLast(students);
            Assert.AreEqual(expected.Length, actual.Count);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i].FirstName, actual[i].FirstName);
                Assert.AreEqual(expected[i].LastName, actual[i].LastName);
            }
        }

        /// <summary>
        ///A test for FindByAge
        ///</summary>
        [TestMethod()]
        public void FindByAgeTest1()
        {
            IEnumerable<Student> students = new Student[] { new Student("a", "b",10), new Student("c", "d",5), new Student("d", "c",0), new Student("b", "a",20) }; // TODO: Initialize to an appropriate value
            Student[] expected = new Student[] { new Student("a", "b",10), new Student("c", "d",5) }; // TODO: Initialize to an appropriate value
            List<Student> actual;
            actual = Student.FirstBeforeLast(students);
            Assert.AreEqual(expected.Length, actual.Count);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i].FirstName, actual[i].FirstName);
                Assert.AreEqual(expected[i].LastName, actual[i].LastName);
                Assert.AreEqual(expected[i].Age, actual[i].Age);
            }
        }
    }
}
